import { _decorator, Component, Label, Node } from 'cc';
const { ccclass, property } = _decorator;


@ccclass('QuickBoxCtrl')
export class QuickBoxCtrl extends Component {
    @property({ type: Label })
    lables: Label[] = [];
    callback: (text: string) => void;

    private _index = 0;
    _chats = [
        "介绍个装修风格",
        "生成一套现代风格的家具",
    ]
    _random = [
        "介绍一些热门的装修风格",
        '生成一些地中海的装修风格',
        "现代简约风格有什么特点",
        "北欧风格适合什么户型",
        "中式风格如何搭配家具",
        '生成一些中式的装修',
        "工业风格装修要注意什么",
        "生成一套现代风格的家具搭配",
        "小户型家具怎么选择",
        "客厅家具布局建议",
        "卧室家具搭配方案",
        "餐厅家具选购指南",
        "如何装修既实用又美观",
        "小户型装修技巧",
        "装修预算如何分配",
        "装修材料怎么选择",
        "装修流程和注意事项"

    ]

    protected start(): void {
        this.lables.forEach((item, index) => {
            item.string = this._chats[index];
        })
        this.updataBox()
    }

    async updataBox() {
        const t = this._random[Math.floor(Math.random() * this._random.length)];
        if (t) {
            this._chats[this._index] = t;
            this.lables[this._index].string = t;
        }
    }


    onClick(event: Event, customEventData: string) {

        const num = Number(customEventData)
        this._index = num;
        const string = this._chats[num];
        this.callback(string)
    }

}

